package com.ruoyi.modules.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CrmRabbitConfig {
    public static final String CRM_QUEUE_CONTRACT_CREATED="crm_queue_contract_created";
    public static final String CRM_EXCHANGE_CONTRACT="crm_exchange_contract";
    public static final String CRM_ROUTING_KEY_CONTRACT_CREATED="crm_routing_key_contract_created";
    //配置队列
    @Bean
    public Queue crmContractCreateQueue(){
        return new Queue(CRM_QUEUE_CONTRACT_CREATED);
    }

    @Bean
    public DirectExchange crmContractDirectExchange(){
        return new DirectExchange(CRM_EXCHANGE_CONTRACT);
    }

    @Bean
    public Binding crmContractBinding(Queue crmContractCreateQueue,DirectExchange crmContractDirectExchange){
        return BindingBuilder.bind(crmContractCreateQueue).to(crmContractDirectExchange).with(CRM_ROUTING_KEY_CONTRACT_CREATED);
    }

}
